#ifndef XBASE_LOGGER_H
#define XBASE_LOGGER_H 1

#ifdef XLOGGER
#include <string>
#include <log4cplus/logger.h>

class LogGuard
{	
	log4cplus::Logger& logger;
	std::string name;

public:
	LogGuard(log4cplus::Logger& a, const std::string& b) : logger( a ), name( b )
	{
		LOG4CPLUS_DEBUG( logger, "======== " << name << " BEGIN ========" );
	}
	~LogGuard()
	{
		LOG4CPLUS_DEBUG( logger, "======== " << name << " END ========" );
	}
};

#define XLOG4CPLUS_DEBUG(a,b) LOG4CPLUS_DEBUG(a,b)
#define XLOG4CPLUS_GUARD(a, b) LogGuard logGuard( a, b )
#define XDECL_LOGGER(logger) static log4cplus::Logger logger;
#define XIMPL_LOGGER(classname, logger) log4cplus::Logger classname::logger = log4cplus::Logger::getInstance(#classname);

#else  // #ifdef XLOGGER
#define XLOG4CPLUS_DEBUG(a,b)
#define XLOG4CPLUS_GUARD(a, b)
#define XDECL_LOGGER(logger)
#define XIMPL_LOGGER(classname, logger)
#endif

#endif // XBASE_LOGGER_H

